home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Demos / SAT Invaders demo ƒ / sShot.c < prev    next >
Text File  |  1994-08-21  |  1KB  |  59 lines

  1. //• C translation from Pascal source file: sShot.p
  2.  
  3. //• ===============================================.
  4. //• ================= Shot sprite unit ================.
  5. //• ===============================================.
  6.  
  7. //• Example file for Ingemars Sprite Animation Toolkit.
  8. //• © Ingemar Ragnemalm 1992.
  9. //• See doc files for legal terms for using this code.
  10.  
  11. //• sShot;
  12.  
  13. //• Sprite unit. A sprite unit should include the following routines:
  14. //• Init-procedure, that Initializes private bitmaps.
  15. //• Setup-procedure, that sets variables other than the standard ones set by MakeSprite.
  16. //• Handle-procedure, to be called once per iteration until the sprite dies.
  17. //• Hittask-procedure (optional), for advanced collission handling.
  18.  
  19. //• Shot object for the SATInvaders sample game.
  20.  
  21. //• Prototypes, etc.
  22.  
  23. #include "SAT.h"
  24. #include "InvadeSAT.h"
  25. //#include "GameGlobals.h"
  26. //SoundConst, GameGlobals;
  27.  
  28. enum {
  29.     shotSpeed = 15
  30. };
  31.  
  32. static FacePtr shotFace;
  33.  
  34. void InitShot ()
  35. {
  36.     shotFace = SATGetFace (135);
  37. }
  38.  
  39. pascal void SetupShot (SpritePtr sp)
  40. {
  41.     sp->face = shotFace;
  42.     SetRect (&sp->hotRect, 0, 0, 8, 12);
  43.     sp->task = &HandleShot;
  44. }
  45.  
  46. pascal void HandleShot (SpritePtr me)
  47. {
  48.     if (me->kind != 1)
  49.     {
  50.         me->task = 0L;
  51.         //• No sound here - we assume that the bad guys (sEnemy and sMissile) do that.
  52.     }
  53.  
  54.     me->position.v = me->position.v - shotSpeed;
  55.     if (me->position.v < 0)
  56.         me->task = 0L;
  57. }
  58.  
  59.